import javax.swing.*;
import java.awt.*;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * Created by ospip on 2017/11/28.
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
public class Encoder extends JFrame {
    private String src = "D:\\1.txt";
    private String target = "D:\\2.txt";

    private JTextArea before, after;
    public Encoder() {
        super("加密解密");
        try {
            UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ());
        }
        catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        this.setSize(1500, 1000);
//        this.setLayout(new BorderLayout(15, 15));
        this.setLayout(new GridLayout(1, 2, 15, 15));
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        before = new JTextArea();
        after = new JTextArea();
        before.setFont(new java.awt.Font("Consolas", 0, 35));
        after.setFont(new java.awt.Font("Consolas", 0, 35));
        this.add("West", new JScrollPane(before));
        this.add("East", new JScrollPane(after));
        try {
            FileReader fin = new FileReader(src);
            FileWriter fout = new FileWriter(target);
            int t;
            while ((t = fin.read()) != -1) {
                before.append((char)t + "");
                if ((char)t == '\n' || (char)t == '\r') fout.write(t);
                else fout.write(t + 1);
            }
            fin.close();
            fout.close();
            fin = new FileReader(target);
            while ((t = fin.read()) != -1) {
                after.append((char)t + "");
            }
            fin.close();
        }
        catch (Exception e){}
    }
    public static void main(String[] args) {
        new Encoder().setVisible(true);
    }
}
